<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算数组中的最大值</title>
    <script>
        function maxArray(array){
            var max = array[0];
            if(array.length == 1) {
                return max;
            }

            for(var i = 1;i < array.length;i++){
                max =  max > array[i] ? max : array[i];
            }
            return max;
        }

        var array = [1,3,5,7,8,6];
        console.log(maxArray(array));
    </script>
</head>
<body>

</body>
</html>